package com.example.langchanin4jdemo1.controller;

import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.service.SystemMessage;
import dev.langchain4j.service.UserMessage;
import dev.langchain4j.service.V;

public class AiServiceDemo2 {
    interface AiWriter {
        @SystemMessage("你是一个知名的散文作家，根据输入的{{title}}，写一篇不超过{{count}}字的散文")
        String write(@UserMessage String message, @V("title") String title, @V("count") Long count);
    }
    public static void main(String[] args) {
        ChatLanguageModel model = QwenChatModel.builder()
                .apiKey("sk-875dd6ef14244431acdc7ccb974f5bfe")
                .modelName("qwen-max")
                .build();
        AiWriter writer = AiServices.create(AiWriter.class, model);
        String response = writer.write("写一篇作文","谁是这个世界上对你最重要的人",200L);
        System.out.println(response);
    }
}
